import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ty_smart_watch/bean/setting_item_bean.dart';
import 'package:ty_smart_watch/common/images_url.dart';
import 'package:ty_smart_watch/route/routes.dart';

import '../../utils/Log.dart';

class SettingList extends StatelessWidget {

  final String mac;
  SettingList({super.key, required this.mac});

  final items = [
    SettingItemBean(WATCH_SETTING, "手表设置", Icons.arrow_forward_ios),
    SettingItemBean(HEALTH_SETTING, "健康数据设置", Icons.arrow_forward_ios),
    SettingItemBean(OTHER_SETTING, "其他功能", Icons.arrow_forward_ios),
  ];

  @override
  Widget build(BuildContext context) {
    return Container(
      // height: 210,
      margin: const EdgeInsets.fromLTRB(10, 10, 10, 0),
      // color: Colors.cyan,
      child: ListView.builder(
        shrinkWrap: true,
        physics: const NeverScrollableScrollPhysics(),
        scrollDirection: Axis.vertical,
        // 设置滚动方向为水平
        itemCount: items.length,
        itemBuilder: (context, index) {
          final item = items[index];
          return Container(
            margin: const EdgeInsets.only(top: 10),
            padding: const EdgeInsets.symmetric(horizontal: 10),
            decoration: BoxDecoration(
              // border: Border(bottom: BorderSide(width: 1, color: Color(0xffe5e5e5)))
              border: Border.all(color: const Color(0xffe5e5e5)),
              borderRadius: BorderRadius.circular(12),
            ),
            child: ListTile(
              splashColor: Colors.transparent,
              onTap: () {
                Log.d('点击了 $index');
                naviTo(index);
              },
              leading: Image.asset(
                item.icon,
                width: 32,
                height: 32,
              ),
              title: Text(item.title),
              trailing: Icon(
                // Icons.arrow_forward_ios,
                item.trailing,
                size: 14,
                color: Colors.grey,
              ),
              contentPadding: const EdgeInsets.symmetric(vertical: 2),
            ),
          );
        },
      ),
    );
  }

  naviTo(int index) {
    Get.toNamed(Routes.watchSettingPage, arguments: {"index": index,"mac":mac});
  }
}
